﻿@model AppsGenerator.Models.Application

@{
    ViewBag.Title = "Create Application";
}

<h2>Create Application</h2>

<style>
    #loading-indicator {
  position: absolute;
  left: 10px;
  top: 10px;
}
</style>

@using (Html.BeginForm()) 
{
    @Html.AntiForgeryToken()
    <div id='ajax_loader' style="position: fixed; left: 50%; top: 50%; display: none;">
        <img src="img/cosmo.png"></img>
    </div>
    
    <div class="form-horizontal">
        <hr />
        @Html.ValidationSummary(true, "", new { @class = "text-danger" })
        <div class="form-group">
            @Html.LabelFor(model => model.Name, htmlAttributes: new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                @Html.EditorFor(model => model.Name, new { htmlAttributes = new { @class = "form-control" } })
                @Html.ValidationMessageFor(model => model.Name, "", new { @class = "text-danger" })
            </div>
        </div>

        <div class="form-group">
            @Html.LabelFor(model => model.url, htmlAttributes: new { @class = "control-label col-md-2" })
            <div class="col-md-4">
                @Html.EditorFor(model => model.url, new { htmlAttributes = new { @class = "form-control" } })
                
                @Html.ValidationMessageFor(model => model.url, "", new { @class = "text-danger" })
            </div>

            <div class="col-md-5">
                <span>
                    <b>
                        .azurewebsites.net
                    </b>
                </span>
                    
                <input id="btnCheckUrl" type="button" value="Check Availability" class="btn btn-success" />
            </div> 

        </div>

        <div class="form-group">
            @Html.LabelFor(model => model.db_datasource, htmlAttributes: new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                @Html.EditorFor(model => model.db_datasource, new { htmlAttributes = new { @class = "form-control" } })
                @Html.ValidationMessageFor(model => model.db_datasource, "", new { @class = "text-danger" })
            </div>
        </div>

        <div class="form-group">
            @Html.LabelFor(model => model.db_name, htmlAttributes: new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                @Html.EditorFor(model => model.db_name, new { htmlAttributes = new { @class = "form-control" } })
                @Html.ValidationMessageFor(model => model.db_name, "", new { @class = "text-danger" })
            </div>
        </div>

        <div class="form-group">
            @Html.LabelFor(model => model.db_user_id, htmlAttributes: new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                @Html.EditorFor(model => model.db_user_id, new { htmlAttributes = new { @class = "form-control" } })
                @Html.ValidationMessageFor(model => model.db_user_id, "", new { @class = "text-danger" })
            </div>
        </div>

        <div class="form-group">
            @Html.LabelFor(model => model.db_password, htmlAttributes: new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                @Html.PasswordFor(model => model.db_password, htmlAttributes: new { @class = "form-control input-md" })
                @Html.ValidationMessageFor(model => model.db_password, "", new { @class = "text-danger" })
            </div>
        </div>

        <div class="form-group">
            <div class="col-md-offset-2 col-md-10">
                <input id="btnCheck" type="button" value="Check Connection" class="btn btn-default" />
                <input type="submit" value="Create" class="btn btn-success" />
            </div>
        </div>
    </div>
}

<div>
    @Html.ActionLink("Back to List", "Index")
</div>

<script src="@Url.Content("~/Scripts/plugins.js")"></script>
<script src="@Url.Content("~/Scripts/app.js")"></script>
